package com.ruoyi.sqlbuilder.execute.relation;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * mysql -> 达梦数据库类型转换关系
 *
 * @author Yanzy
 */
public class MysqlToDmColumnType {

    private static Map<String, String> relation = new ConcurrentHashMap<>();

    static {
        //  mysql字段类型 --> dm字段类型
        relation.put("bigint", "BIGINT");
        relation.put("blob", "CLOB");
        relation.put("char", "VARCHAR");
        relation.put("date", "TIMESTAMP");
        relation.put("datetime", "TIMESTAMP");
        relation.put("decimal", "DOUBLE PRECISION");
        relation.put("double", "DOUBLE PRECISION");
        relation.put("float", "FLOAT");
        relation.put("int", "INTEGER");
        relation.put("longblob", "CLOB");
        relation.put("longtext", "TEXT");
        relation.put("mediumint", "INTEGER");
        relation.put("mediumtext", "TEXT");
        relation.put("smallint", "SMALLINT");
        relation.put("text", "TEXT");
        relation.put("mediumblob", "CLOB");
        relation.put("time", "TIMESTAMP");
        relation.put("timestamp", "TIMESTAMP");
        relation.put("tinyblob", "CLOB");
        relation.put("tinyint", "TINYINT");
        relation.put("tinytext", "TEXT");
        relation.put("varchar", "VARCHAR");
        relation.put("year", "TIMESTAMP");
    }

    /**
     * 获取字段类型对应转换
     * @param type mysql字段类型
     * @return dm字段类型
     */
    public static String getRelationType(String type) {
        return relation.get(type.toLowerCase());
    }
}
